package com.sdu.cloudservice.action;

import com.sdu.cloudservice.dto.Envelope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;


/**
 * Create by zekdot on 19-6-19.
 */
@Controller
@RequestMapping("/testUser")
public class TestUserAction {

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public String login(HttpSession session, String username){
        session.setAttribute("user",username);
        System.out.println(username);
        return Envelope.success.toString();
    }

    @RequestMapping("/userInfo")
    @ResponseBody
    public String getInfo(HttpSession session){
        return new Envelope(session.getAttribute("user")).toString();
    }
}
